package it.upnp.device;
import org.apache.log4j.Logger;
import org.cybergarage.upnp.Action;
import org.cybergarage.upnp.ActionList;
import org.cybergarage.upnp.Device;
import org.cybergarage.upnp.DeviceList;
import org.cybergarage.upnp.Service;
import org.cybergarage.upnp.ServiceList;
import org.cybergarage.upnp.ServiceStateTable;
import org.cybergarage.upnp.StateVariable;


public class DeviceUtilities {
	
	public static void printDevices(Device device, Logger logger) {
		
		logger.debug(device.getFriendlyName());
		
		DeviceList devList = device.getDeviceList();
		for(int i=0 ; i<devList.size() ; i++) {
			Device dev = devList.getDevice(i);
			printDevices(dev, logger);
		}
		
	}

	public static void printServices(Device device, Logger logger) {
		
		ServiceList serviceList = device.getServiceList();
		for(int i=0 ; i<serviceList.size() ; i++) {
			Service service = serviceList.getService(i);
			
			/* Action */
			ActionList actionList = service.getActionList();
			for(int n=0 ; n<actionList.size() ; n++) {
				Action action = actionList.getAction(n);
				logger.debug("action[" + n + "] " + action.getName());
			}
			
			/* StateVariable */
			ServiceStateTable serviceStateTable = service.getServiceStateTable();
			for(int n=0 ; n<serviceStateTable.size() ; n++) {
				StateVariable stateVariable = serviceStateTable.getStateVariable(n);
				logger.debug("stateVar[" + n + "] " + stateVariable.getName());
			}
		}
		
	}
	
}
